// import com.alibaba.druid.sql.ast.SQLExpr;
// import com.alibaba.druid.sql.ast.SQLName;
// import com.alibaba.druid.sql.ast.SQLObject;
// import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlASTVisitor;

// import java.util.ArrayList;
// import java.util.List;

#include "MySqlExecuteStatement.h"
#include "../../../../ast/SQLExpr.h"
#include "../../../../ast/SQLName.h"
#include "../../../../ast/SQLObject.h"
#include "../../visitor/MySqlASTVisitor.h"
#include "../../../../../utils/listTran.h"

MySqlExecuteStatement::MySqlExecuteStatement()
{
  parameters = std::make_shared<std::list<SQLExpr_ptr>>();
}
SQLName_ptr MySqlExecuteStatement::getStatementName()
{
  return statementName;
}

void MySqlExecuteStatement::setStatementName(SQLName_ptr statementName)
{
  this->statementName = statementName;
}

SQLExpr_list_ptr MySqlExecuteStatement::getParameters()
{
  return parameters;
}

void MySqlExecuteStatement::accept0(MySqlASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(MySqlExecuteStatement)))
  {
    acceptChild(visitor, statementName);
    SQLObject_list_ptr tmp = ListTran::tran_class<SQLExpr, SQLObject>(parameters);
    acceptChild(visitor, tmp);
  }
  visitor->endVisit(SharedObject(MySqlExecuteStatement));
}

// @Override
SQLObject_list_ptr MySqlExecuteStatement::getChildren()
{
  SQLObject_list_ptr children = std::make_shared<std::list<SQLObject_ptr>>();
  if (statementName != nullptr)
  {
    children->push_back(statementName);
  }
  // children.addAll(this.parameters);
  for (auto it : *this->parameters)
  {
    children->push_back(it);
  }
  return children;
}
